
package com.sxkj.service.version;

import com.github.pagehelper.PageInfo;
import com.sxkj.entity.entity.version.VersionScaleRecord;
import com.sxkj.entity.mapper.version.VersionScaleRecordMapper;
import com.sxkj.service.base.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author Zhang Xingliang
 *
 * @description: 秤更新状态记录
 * @date 2019-12-31 13:25:41
 */
@Service
public class VersionScaleRecordService extends BaseService<VersionScaleRecordMapper,VersionScaleRecord> {

	/**
	* 获取单条数据
	* @param id
	* @return VersionScaleRecord
	*/
	public VersionScaleRecord get(String id) throws Exception{
		return super.get(id);
	}
	
	/**
	* 获取单条数据
	* @param versionScaleRecord
	* @return VersionScaleRecord
	*/
	public VersionScaleRecord get(VersionScaleRecord versionScaleRecord) throws Exception{
		return super.get(versionScaleRecord);
	}
	
	/**
	* 查询列表数据
	* @param versionScaleRecord
	* @return List<VersionScaleRecord>
	*/
	public List<VersionScaleRecord> findList(VersionScaleRecord versionScaleRecord) throws Exception{
		return super.findList(versionScaleRecord);
	}

	/**
	* 查询分页数据
	* @param versionScaleRecord
	* @param pageSize
	* @param pageNum
	* @return Page
	*/
	public PageInfo findPage(VersionScaleRecord versionScaleRecord, Integer pageSize, Integer pageNum) throws Exception{
		return super.findPage(versionScaleRecord, pageSize, pageNum);
	}

	/**
	* 保存数据（插入或更新）
	* @param versionScaleRecord
	*/
	@Transactional(rollbackFor = Exception.class)
	public void save(VersionScaleRecord versionScaleRecord) throws Exception{



		super.save(versionScaleRecord);
	}

	/**
	* 删除数据
	* @param versionScaleRecord
	*/
	@Transactional(rollbackFor = Exception.class)
	public void delete(VersionScaleRecord versionScaleRecord) throws Exception{
		super.delete(versionScaleRecord);
	}


	/**
	 * @author Zhang Xingliang
	 * @description 获取版本信息之后存入记录
	 * @date 10:22 2019/11/19
	 * @param versionScaleRecord
	 * @return com.jkr.modules.business.vo.VersionVendorRecordVo
	 **/
	public VersionScaleRecord saveVersionVendorRecord(VersionScaleRecord versionScaleRecord){
		//获取信息版本信息记录
		versionScaleRecord.setInstallFlag(0);
		versionScaleRecord.setInfoFlag(1);
		versionScaleRecord.setDownloadFlag(0);
//		versionScaleRecord.setStatus(0);
		baseMapper.insert(versionScaleRecord);
		return null;
	}

	/**
	 * @author Zhang Xingliang
	 * @description 更新版本信息记录状态
	 * @date 10:22 2019/11/19
	 * @param versionScaleRecord
	 * 			InstallFlag 0未安装 1已安装
	 * 			DownloadFlag 0未下载 1已下载
	 * 			Status 0未安装 1已安装
	 * @return com.jkr.modules.business.vo.VersionVendorRecordVo
	 **/
	public VersionScaleRecord updateVersionScaleRecord(VersionScaleRecord versionScaleRecord){
		VersionScaleRecord queryVersionScaleRecord = baseMapper.get(versionScaleRecord);//用户
		if( null !=queryVersionScaleRecord ){
			if(null != versionScaleRecord.getDownloadFlag()){
				queryVersionScaleRecord.setDownloadFlag(versionScaleRecord.getDownloadFlag());
			}

			if(null != versionScaleRecord.getInstallFlag()){
				queryVersionScaleRecord.setInstallFlag(versionScaleRecord.getInstallFlag());
			}

			if(null != versionScaleRecord.getInstallFlag()){
				queryVersionScaleRecord.setStatus(versionScaleRecord.getStatus());
			}

			if(null != versionScaleRecord.getStatus()){
				queryVersionScaleRecord.setStatus(versionScaleRecord.getStatus());
			}

			baseMapper.update(queryVersionScaleRecord);
		}
		return null;
	}
}